home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / ResourceTable.cpp < prev    next >
C/C++ Source or Header  |  1997-08-07  |  20KB  |  816 lines

  1. /*
  2.  *  File:       ResourceTable.cpp
  3.  *  Summary:       THierarchicalTable subclass displaying the resources in a document.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996-1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <2>     5/04/97    JDJ        Added mPens.
  12.  *         <1>     1/17/96    JDJ        Created
  13.  */
  14.  
  15. #include "ResourceTable.h"
  16.  
  17. #include <ZContextMenu.h>
  18. #include <ZDocWindow.h>
  19. #include <ZDragSession.h>
  20. #include <ZHandleStream.h>
  21. #include <ZHierarchicalTableExtras.h>
  22. #include <ZGWorld.h>
  23. #include <ZMiscUtils.h>
  24. #include <ZStringUtils.h>
  25. #include <ZUndoMgr.h>
  26.  
  27. #include "Constants.h"
  28. #include "Document.h"
  29. #include "PenNode.h"
  30. #include "ResourceCommands.h"
  31. #include "ResourceInfoDialog.h"
  32. #include "ResourcePicker.h"
  33. #include "ResourceSubNode.h"
  34. #include "TextTraitsNode.h"
  35. #include "ViewNode.h"
  36. #include "WindowNode.h"
  37.  
  38.  
  39. // ===================================================================================
  40. //    class CDropResourceCommand
  41. // ===================================================================================
  42. class CDropResourceCommand : public TUndoableCommand {
  43.  
  44.     typedef TUndoableCommand Inherited;
  45.  
  46. //-----------------------------------
  47. //    Initialization/Destruction
  48. //
  49. public:
  50.     virtual             ~CDropResourceCommand();
  51.     
  52.                         CDropResourceCommand(CResourceTable* object, TUndoMgr* context);
  53.     
  54. //-----------------------------------
  55. //    Inherited API
  56. //
  57. public:
  58.     virtual void         Post();
  59.  
  60.     virtual string        GetText() const;
  61.  
  62. protected:
  63.     virtual void         OnDo();
  64.  
  65.     virtual void         OnUndo();
  66.  
  67.     virtual void         OnRedo();
  68.             
  69. //-----------------------------------
  70. //    Member data
  71. //
  72. protected:
  73.     CResourceTable*    mTable;
  74.     THandle            mOldState;
  75.     THandle            mNewState;
  76. };
  77.  
  78.  
  79. //---------------------------------------------------------------
  80. //
  81. // CDropResourceCommand::~CDropResourceCommand
  82. //
  83. //---------------------------------------------------------------
  84. CDropResourceCommand::~CDropResourceCommand()
  85. {
  86. }
  87.  
  88.  
  89. //---------------------------------------------------------------
  90. //
  91. // CDropResourceCommand::CDropResourceCommand
  92. //
  93. //---------------------------------------------------------------
  94. CDropResourceCommand::CDropResourceCommand(CResourceTable* object, TUndoMgr* context) : TUndoableCommand(context)
  95. {
  96.     ASSERT(object != nil);
  97.     
  98.     mTable = object;
  99.     
  100.     mOldState = mTable->GetState();
  101. }
  102.  
  103.  
  104. //---------------------------------------------------------------
  105. //
  106. // CDropResourceCommand::Post
  107. //
  108. //---------------------------------------------------------------
  109. void CDropResourceCommand::Post()
  110. {
  111.     mNewState = mTable->GetState();
  112.     
  113.     Inherited::Post();
  114. }
  115.  
  116.  
  117. //---------------------------------------------------------------
  118. //
  119. // CDropResourceCommand::GetText
  120. //
  121. //---------------------------------------------------------------
  122. string CDropResourceCommand::GetText() const
  123. {
  124.     return LoadIndString(256, 1);
  125. }
  126.  
  127.  
  128. //---------------------------------------------------------------
  129. //
  130. // CDropResourceCommand::OnDo
  131. //
  132. //---------------------------------------------------------------
  133. void CDropResourceCommand::OnDo()
  134. {
  135.     // nothing to do
  136. }
  137.  
  138.  
  139. //---------------------------------------------------------------
  140. //
  141. // CDropResourceCommand::OnUndo
  142. //
  143. //---------------------------------------------------------------
  144. void CDropResourceCommand::OnUndo()
  145. {
  146.     mTable->SetState(mOldState);
  147. }
  148.  
  149.  
  150. //---------------------------------------------------------------
  151. //
  152. // CDropResourceCommand::OnRedo
  153. //
  154. //---------------------------------------------------------------
  155. void CDropResourceCommand::OnRedo()
  156. {
  157.     mTable->SetState(mNewState);
  158. }
  159.  
  160. #pragma mark -
  161.  
  162. // ===================================================================================
  163. //    class CResourceTable
  164. // ===================================================================================
  165.  
  166. static TReanimatorRegister<CResourceTable> sResourceTableRegistrar;
  167.  
  168. //---------------------------------------------------------------
  169. //
  170. // CResourceTable::~CResourceTable
  171. //
  172. //---------------------------------------------------------------
  173. CResourceTable::~CResourceTable()
  174. {
  175.     delete mDragImage;
  176. }
  177.  
  178.  
  179. //---------------------------------------------------------------
  180. //
  181. // CResourceTable::CResourceTable (string, TView*, TRect, MCommander*)
  182. //
  183. //---------------------------------------------------------------
  184. CResourceTable::CResourceTable(const string& name, TView* superView, const TRect& frame, MCommander* super) : THierarchicalTable(name, superView, frame, super, true)
  185. {
  186.     mWindows    = nil;
  187.     mViews      = nil;
  188.     mTextTraits = nil;
  189.     mPens       = nil;
  190.  
  191.     mDragImage = nil;
  192. }
  193.  
  194.  
  195. //---------------------------------------------------------------
  196. //
  197. // CResourceTable::Create                                [static]
  198. //
  199. //---------------------------------------------------------------
  200. MReanimatable* CResourceTable::Create(MReanimatable* parent)
  201. {
  202.     return new CResourceTable("????", dynamic_cast<TView*>(parent), TRect(0, 0, 100, 100), nil);
  203. }
  204.  
  205.  
  206. //---------------------------------------------------------------
  207. //
  208. // CResourceTable::HasSelection
  209. //
  210. //---------------------------------------------------------------
  211. bool CResourceTable::HasSelection() const
  212. {
  213.     return Inherited::HasSelection();
  214. }
  215.  
  216.  
  217. //---------------------------------------------------------------
  218. //
  219. // CResourceTable::GetState
  220. //
  221. //---------------------------------------------------------------
  222. CResourceTable::SState CResourceTable::GetState() const
  223. {
  224.     TOutHandleStream stream;
  225.     
  226.     mWindows->DoSaveState(stream);
  227.     mViews->DoSaveState(stream);
  228.     mTextTraits->DoSaveState(stream);
  229.     mPens->DoSaveState(stream);
  230.     
  231.     return stream.GetHandle();
  232. }
  233.  
  234.  
  235. //---------------------------------------------------------------
  236. //
  237. // CResourceTable::SetState
  238. //
  239. //---------------------------------------------------------------
  240. void CResourceTable::SetState(const SState& state)
  241. {
  242.     TInHandleStream stream(state);
  243.  
  244.     mWindows->DoRestoreState(stream);
  245.     mViews->DoRestoreState(stream);
  246.     mTextTraits->DoRestoreState(stream);
  247.     mPens->DoRestoreState(stream);
  248. }
  249.  
  250. #pragma mark ハ
  251.  
  252. //---------------------------------------------------------------
  253. //
  254. // CResourceTable::Invariant
  255. //
  256. //---------------------------------------------------------------
  257. void CResourceTable::Invariant() const
  258. {
  259.     Inherited::Invariant();
  260.     
  261.     // Drag Manager requires a window.
  262.     TView* topView = this->GetTopView();
  263.     TWindow* window = dynamic_cast<TWindow*>(topView);
  264.     ASSERT(window != nil);
  265. }
  266.  
  267.  
  268. //---------------------------------------------------------------
  269. //
  270. // CResourceTable::OnReanimated
  271. //
  272. //---------------------------------------------------------------
  273. void CResourceTable::OnReanimated()
  274. {
  275.     Inherited::OnReanimated();
  276.     
  277.     TSubNode* root = this->GetRoot();
  278.     TDocWindow* window = dynamic_cast<TDocWindow*>(this->GetSuperCommander());
  279.     CDocument* doc = dynamic_cast<CDocument*>(window->GetSuperCommander());
  280.     
  281.     CResourceNode* exemplar = nil;
  282.     
  283.     exemplar = new CWindowNode(this, doc->GetWindowMap()); 
  284.     mWindows = new CResourceSubNode(this, root, "Windows", exemplar);
  285.     root->AppendNode(mWindows);
  286.     
  287.     exemplar = new CViewNode(this, doc->GetViewMap()); 
  288.     mViews = new CResourceSubNode(this, root, "Views", exemplar);
  289.     root->AppendNode(mViews);
  290.     
  291.     exemplar = new CTextTraitsNode(this, doc->GetTraitsMap()); 
  292.     mTextTraits = new CResourceSubNode(this, root, "Text Traits", exemplar);
  293.     root->AppendNode(mTextTraits);    
  294.     
  295.     exemplar = new CPenNode(this, doc->GetPensMap()); 
  296.     mPens = new CResourceSubNode(this, root, "Pen", exemplar);
  297.     root->AppendNode(mPens);    
  298. }
  299.  
  300.  
  301. //---------------------------------------------------------------
  302. //
  303. // CResourceTable::OnMouseDown
  304. //
  305. //---------------------------------------------------------------
  306. bool CResourceTable::OnMouseDown(const TMouseEvent& event)
  307. {
  308.     bool handled = false;
  309.     
  310.     TBaseTableNode* node = mRootNode->FindNode(event.GetPosition());
  311.  
  312.     // Note that we cannot call WaitMouseMoved with TSubNode's
  313.     // because they need to track the mouse when it lands in a
  314.     // disclosure arrow (WaitMouseMoved blocks until the mouse
  315.     // is moved or released).
  316.     if (node != nil && dynamic_cast<TSubNode*>(node) == nil) {
  317.         if (::WaitMouseMoved(event.GetGlobalPosition())) {
  318.             if (!node->IsSelected()) {
  319.                 if (event.WasShiftKeyDown() || event.WasCommandKeyDown())
  320.                     this->Select(node);
  321.                 else
  322.                     this->SelectOneNode(node);
  323.                 this->HandleUpdate();
  324.             }
  325.             
  326.             this->HandleDragStart(event);
  327.             
  328.             handled = true;
  329.         } 
  330.     }
  331.         
  332.     if (!handled)
  333.         handled = Inherited::OnMouseDown(event);
  334.         
  335.     return handled;
  336. }
  337.  
  338.  
  339. //---------------------------------------------------------------
  340. //
  341. // CResourceTable::OnContextMenu
  342. //
  343. //---------------------------------------------------------------
  344. bool CResourceTable::OnContextMenu(const TMouseEvent& event)
  345. {
  346.     if (!Inherited::OnContextMenu(event)) {
  347.         TContextMenu* popup = new TContextMenu(this, event.GetGlobalPosition(), 301);
  348.         popup->Post();
  349.     }
  350.     
  351.     return kHandled;
  352. }
  353.  
  354.  
  355. //---------------------------------------------------------------
  356. //
  357. // CResourceTable::OnCopy
  358. //
  359. //---------------------------------------------------------------
  360. void CResourceTable::OnCopy(OSType type, TOutStream& stream)
  361. {
  362.     switch (type) {
  363.         case 'Wind':
  364.             if (mWindows->HasSelection())
  365.                 mWindows->DoCopy(stream);
  366.             break;
  367.             
  368.         case 'View':
  369.             if (mViews->HasSelection())
  370.                 mViews->DoCopy(stream);
  371.             break;
  372.             
  373.         case 'Txtr':
  374.             if (mTextTraits->HasSelection())
  375.                 mTextTraits->DoCopy(stream);
  376.             break;
  377.         
  378.         case 'Pen ':
  379.             if (mPens->HasSelection())
  380.                 mPens->DoCopy(stream);
  381.             break;
  382.         
  383.         default:
  384.             DEBUGSTR("CResourceTable::OnCopy got a bogus type: %.4s", type);
  385.     }
  386. }
  387.  
  388.  
  389. //---------------------------------------------------------------
  390. //
  391. // CResourceTable::OnPaste
  392. //
  393. //---------------------------------------------------------------
  394. void CResourceTable::OnPaste(OSType type, TInStream& stream)
  395. {
  396.     switch (type) {
  397.         case 'Wind':
  398.             mWindows->DoPaste(stream);
  399.             break;
  400.             
  401.         case 'View':
  402.             mViews->DoPaste(stream);
  403.             break;
  404.             
  405.         case 'Txtr':
  406.             mTextTraits->DoPaste(stream);
  407.             break;
  408.         
  409.         case 'Pen ':
  410.             mPens->DoPaste(stream);
  411.             break;
  412.         
  413.         default:
  414.             DEBUGSTR("CResourceTable::OnPaste got a bogus type: %.4s", type);
  415.     }
  416. }
  417.  
  418.  
  419. //---------------------------------------------------------------
  420. //
  421. // CResourceTable::OnClear
  422. //
  423. //---------------------------------------------------------------
  424. void CResourceTable::OnClear()
  425. {
  426.     mWindows->DoClear();
  427.     mViews->DoClear();
  428.     mTextTraits->DoClear();
  429.     mPens->DoClear();
  430. }
  431.  
  432.  
  433. //---------------------------------------------------------------
  434. //
  435. // CResourceTable::GetCopyCount
  436. //
  437. //---------------------------------------------------------------
  438. ulong CResourceTable::GetCopyCount() const
  439. {
  440.     return 3;
  441. }
  442.  
  443.     
  444. //---------------------------------------------------------------
  445. //
  446. // CResourceTable::GetCopyType
  447. //
  448. //---------------------------------------------------------------
  449. OSType CResourceTable::GetCopyType(ulong index) const
  450. {
  451.     OSType type = '????';
  452.     
  453.     switch (index) {
  454.         case 0:
  455.             type = 'Wind';
  456.             break;
  457.             
  458.         case 1:
  459.             type = 'View';
  460.             break;
  461.             
  462.         case 2:
  463.             type = 'Txtr';
  464.             break;
  465.         
  466.         default:
  467.             DEBUGSTR("CResourceTable::GetCopyType got a bogus index: %d", index);
  468.     }
  469.     
  470.     return type;
  471. }
  472.  
  473.     
  474. //---------------------------------------------------------------
  475. //
  476. // CResourceTable::GetPasteCount
  477. //
  478. //---------------------------------------------------------------
  479. ulong CResourceTable::GetPasteCount() const
  480. {
  481.     return 3;
  482. }
  483.  
  484.     
  485. //---------------------------------------------------------------
  486. //
  487. // CResourceTable::GetPasteType
  488. //
  489. //---------------------------------------------------------------
  490. OSType CResourceTable::GetPasteType(ulong index) const
  491. {
  492.     OSType type = '????';
  493.     
  494.     switch (index) {
  495.         case 0:
  496.             type = 'Wind';
  497.             break;
  498.             
  499.         case 1:
  500.             type = 'View';
  501.             break;
  502.             
  503.         case 2:
  504.             type = 'Txtr';
  505.             break;
  506.         
  507.         default:
  508.             DEBUGSTR("CResourceTable::GetPasteType got a bogus index: %d", index);
  509.     }
  510.     
  511.     return type;
  512. }
  513.  
  514.         
  515. //---------------------------------------------------------------
  516. //
  517. // CResourceTable::OnAddDragData
  518. //
  519. //---------------------------------------------------------------
  520. void CResourceTable::OnAddDragData(TDragSession& session, const TMouseEvent& event)
  521. {
  522.     #pragma unused(event)
  523.     
  524.     long selectCount = 0;
  525.     
  526.     CResourceNode* node = nil;
  527.  
  528.     // For every selected item:
  529.     THierarchicalIter<CResourceNode> iter(this);
  530.     while (iter) {
  531.         node = *iter;
  532.         ++iter;
  533.         
  534.         if (node->IsSelected()) {
  535.             node->UpdateResource();
  536.  
  537.             const SResource& rsrc = node->GetResource();
  538.             selectCount++;
  539.             
  540.             // add the resource flavor (note that this is hidden from other apps)
  541.             FlavorType flavor = node->GetMap()->GetType();
  542.             rsrc.AddData(session, selectCount, flavor, flavorSenderOnly);
  543.  
  544.             // add the drag region
  545.             if (node->IsVisible()) {
  546.                 TRect dragRect = node->GetBounds();
  547.                 dragRect = this->LocalToPort(dragRect);
  548.                 dragRect = this->PortToGlobal(dragRect);
  549.  
  550.                 session.AddDragRgn(selectCount, dragRect);
  551.             }
  552.         }
  553.     }
  554.     
  555. #if 0
  556.     // Add an image for the way-cool translucent drag manager.
  557.     if (UGestalt::hasTranslucentDrag && selectCount > 0) {        // don't do any work we don't have to
  558.  
  559.         // Find the index for one of the items in the middle.
  560.         selectCount /= 2;
  561.         iter = THierarchicalIter<CResourceNode>(this);
  562.         while (iter && selectCount != 0) {
  563.             node = *iter;
  564.             ++iter;
  565.             
  566.             if (node->IsSelected())
  567.                 selectCount--;
  568.         }
  569.         
  570.         TRect cellBounds = node->GetBounds();
  571.         TRect itemBounds = TRect(kZeroPt, cellBounds.GetSize());
  572.         
  573.         // Create a GWorld of the correct size.
  574.         if (mDragImage == nil)
  575.             mDragImage = new TGWorld(itemBounds.GetSize(), nil, 8);
  576.         else
  577.             mDragImage->SetSize(itemBounds.GetSize());
  578.                 
  579.         const SResource& rsrc = node->GetResource();
  580.         
  581.         {
  582.         // Draw one of the items into the GWorld.
  583.         TPortCanvas canvas(mDragImage->GetPort());
  584.         
  585.             TRectShape::Fill(canvas, itemBounds, kRGBWhite);
  586.         
  587.             bool prevSelected = false;
  588.             if (index > 0)
  589.                 prevSelected = mSelected[index-1];
  590.  
  591.             bool nextSelected = false;
  592.             if (index+1 < this->GetCount())
  593.                 nextSelected = mSelected[index+1];
  594.  
  595.             this->OnDrawSelection(canvas, itemBounds, prevSelected, nextSelected);
  596.  
  597.             this->OnDrawCell(canvas, itemBounds, mItems[index], mSelected[index]);
  598.         }
  599.         
  600.         // Add the GWorld's pixelMap to the drag session.
  601.         TPoint offset = this->PortToGlobal(this->LocalToPort(cellBounds[topLeft]));
  602.         session.SetDragImage(mDragImage->GetPixMap(), offset);
  603.     }
  604. #endif
  605. }
  606.  
  607.                         
  608. //---------------------------------------------------------------
  609. //
  610. // CResourceTable::OnDragStop
  611. //
  612. //---------------------------------------------------------------
  613. void CResourceTable::OnDragStop(const TMouseEvent& event, bool dragged)
  614. {
  615.     // GWorlds are pretty expensive to construct so we'll just
  616.     // shrink it in case we need it again.
  617.     if (mDragImage != nil)
  618.         mDragImage->SetSize(TSize(4, 4));
  619.     
  620.     MDragSource::OnDragStop(event, dragged);
  621. }
  622.  
  623.  
  624. //---------------------------------------------------------------
  625. //
  626. // CResourceTable::OnGetDragWindow
  627. //
  628. //---------------------------------------------------------------
  629. WindowRef CResourceTable::OnGetDragWindow() const
  630. {
  631.     TView* topView = this->GetTopView();
  632.     TWindow* window = dynamic_cast<TWindow*>(topView);
  633.     ASSERT(window != nil);
  634.     
  635.     return window->GetWindowRef();
  636. }
  637.  
  638.  
  639. //---------------------------------------------------------------
  640. //
  641. // CResourceTable::OnGetDropRegion
  642. //
  643. //---------------------------------------------------------------
  644. TRegion CResourceTable::OnGetDropRegion()
  645. {
  646.     TRect extent = this->GetExtent();
  647.  
  648.     extent = this->LocalToPort(extent);
  649.     extent = this->PortToGlobal(extent);
  650.  
  651.     return extent;
  652. }
  653.  
  654.  
  655. //---------------------------------------------------------------
  656. //
  657. // CResourceTable::OnCanAcceptDrag
  658. //
  659. //---------------------------------------------------------------
  660. bool CResourceTable::OnCanAcceptDrag(ItemReference item, const TDragSession& session)
  661. {
  662.     bool hasFlavor = session.HasFlavor(item, 'Wind') || session.HasFlavor(item, 'View') || session.HasFlavor(item, 'Txtr');
  663.  
  664.     return hasFlavor && msSourceTarget != this;
  665. }
  666.  
  667.  
  668. //---------------------------------------------------------------
  669. //
  670. // CResourceTable::OnDragReceive
  671. //
  672. //---------------------------------------------------------------
  673. void CResourceTable::OnDragReceive(const TDragSession& session)
  674. {
  675.     TView* topView = this->GetTopView();
  676.     TWindow* window = dynamic_cast<TWindow*>(topView);
  677.     TUndoableCommand* command = new CDropResourceCommand(this, window->GetUndoContext());
  678.     
  679.     long count = session.GetItemCount();
  680.     for (long index = 0; index < count; index++) {
  681.         ItemReference item = session.GetItemReference(index);
  682.         
  683.         SResource rsrc;
  684.         
  685.         if (session.HasFlavor(item, 'Wind')) {
  686.             rsrc = SResource(session, item, 'Wind');
  687.             
  688.             mWindows->DoAddResource(rsrc);
  689.         }
  690.         
  691.         if (session.HasFlavor(item, 'View')) {
  692.             rsrc = SResource(session, item, 'View');
  693.             
  694.             mViews->DoAddResource(rsrc);
  695.         }
  696.         
  697.         if (session.HasFlavor(item, 'Txtr')) {
  698.             rsrc = SResource(session, item, 'Txtr');
  699.             
  700.             mTextTraits->DoAddResource(rsrc);
  701.         }
  702.         
  703.         if (session.HasFlavor(item, 'Pen ')) {
  704.             rsrc = SResource(session, item, 'Pen ');
  705.             
  706.             mPens->DoAddResource(rsrc);
  707.         }
  708.     }
  709.     
  710.     command->Post();
  711. }
  712.  
  713.  
  714. //---------------------------------------------------------------
  715. //
  716. // CResourceTable::OnKeyDown
  717. //
  718. //---------------------------------------------------------------
  719. bool CResourceTable::OnKeyDown(const TKeyEvent& event)
  720. {
  721.     bool handled = this->HandleEditKey(this, event);
  722.     
  723.     if (!handled) 
  724.         handled = Inherited::OnKeyDown(event);
  725.     
  726.     return handled;
  727. }
  728.  
  729.  
  730. //---------------------------------------------------------------
  731. //
  732. // CResourceTable::OnMenuCommand
  733. //
  734. //---------------------------------------------------------------
  735. bool CResourceTable::OnMenuCommand(const MenuCommand& cmd)
  736. {
  737.     bool handled = true;
  738.     
  739.     TCommand* command = nil;
  740.  
  741.     if (cmd == kDuplicateCmd && this->HasSelection()) {
  742.         command = new CDuplicateResourceCommand(this);
  743.         command->Post();
  744.  
  745.     } else if (cmd == kCreateCmd) {
  746.         CResourceSubNode* subNode = ::PickResource(this);
  747.         if (subNode != nil) {
  748.             command = new CCreateResourceCommand(subNode);
  749.             command->Post();
  750.         }
  751.         
  752.     } else if (cmd == kInfoCmd && this->HasOneSelection()) {
  753.         this->DoChangeInfo();
  754.         
  755.     } else
  756.         handled = this->HandleEditCommand(this, cmd);
  757.     
  758.     if (!handled)
  759.         handled = Inherited::OnMenuCommand(cmd);
  760.     
  761.     return handled;
  762. }
  763.  
  764.         
  765. //---------------------------------------------------------------
  766. //
  767. // CResourceTable::OnCommandStatus
  768. //
  769. //---------------------------------------------------------------
  770. bool CResourceTable::OnCommandStatus(const MenuCommand& command, SCommandStatus& status)
  771. {
  772.     bool handled = true;
  773.     
  774.     if (command == kDuplicateCmd) {
  775.         status.enabled = this->HasSelection();
  776.             
  777.     } else if (command == kCreateCmd) {
  778.         status.enabled = true;
  779.             
  780.     } else if (command == kInfoCmd) {
  781.         status.enabled = this->HasOneSelection();
  782.                         
  783.     } else {
  784.         handled = this->HandleEditCommandStatus(command, status);
  785.     }
  786.     
  787.     if (!handled)
  788.         handled = Inherited::OnCommandStatus(command, status);
  789.  
  790.     return handled;
  791. }
  792.  
  793. #pragma mark ハ
  794.  
  795. //---------------------------------------------------------------
  796. //
  797. // CResourceTable::DoChangeInfo
  798. //
  799. //---------------------------------------------------------------
  800. void CResourceTable::DoChangeInfo()
  801. {
  802.     CResourceNode* node = dynamic_cast<CResourceNode*>(this->GetSelection());
  803.     const SResource& oldRsrc = node->GetResource();
  804.     
  805.     SResource newRsrc;
  806.     
  807.     if (CResourceInfoDialog::Pose(node->GetMap(), oldRsrc, &newRsrc)) {
  808.         if (oldRsrc.id != newRsrc.id || oldRsrc.name != newRsrc.name) {
  809.             TCommand* command = new CResourceInfoCommand(node, oldRsrc.id, oldRsrc.name, newRsrc.id, newRsrc.name);
  810.             command->Post();
  811.         }
  812.     }
  813. }
  814.  
  815.  
  816.